load("@rules_license//rules:license.bzl", "license")

package(
    default_applicable_licenses = [":license"],
    features = [
        "layering_check",
    ],
)

license(
    name = "license",
    package_name = "bullet",
    license_kinds = [
        "@rules_license//licenses/spdx:Zlib",
    ],
    license_text = ":LICENSE.txt",
)

cc_library(
    name = "LinearMath",
    srcs = glob(["src/LinearMath/*.cpp"]),
    hdrs = glob([
        "src/LinearMath/*.h",
        "src/LinearMath/**/*.h",
    ]),
    copts = select({
        "@platforms//os:windows": [],
        "//conditions:default": [
            "-Wno-reorder",
        ],
    }),
    visibility = ["//visibility:public"],
)

cc_library(
    name = "LinearMathDoublePrecision",
    srcs = glob(["src/LinearMath/*.cpp"]),
    hdrs = glob([
        "src/LinearMath/*.h",
        "src/LinearMath/**/*.h",
    ]),
    copts = select({
        "@platforms//os:windows": [],
        "//conditions:default": [
            "-Wno-reorder",
        ],
    }),
    defines = [
        "BT_USE_DOUBLE_PRECISION",
    ],
    visibility = ["//visibility:public"],
)

cc_library(
    name = "BulletCollision",
    srcs = glob([
        "src/BulletCollision/**/*.cpp",
    ]),
    hdrs = glob([
        "src/BulletCollision/**/*.h",
    ]) + ["src/btBulletCollisionCommon.h"],
    copts = select({
        "@platforms//os:windows": [],
        "//conditions:default": [
            "-Wno-sign-compare",
            "-Wno-unused-but-set-variable",
            "-Wno-unused-variable",
        ],
    }),
    includes = ["src"],
    visibility = ["//visibility:public"],
    deps = [":LinearMath"],
)

cc_library(
    name = "BulletCollisionDoublePrecision",
    srcs = glob([
        "src/BulletCollision/**/*.cpp",
    ]),
    hdrs = glob([
        "src/BulletCollision/**/*.h",
    ]) + ["src/btBulletCollisionCommon.h"],
    copts = select({
        "@platforms//os:windows": [],
        "//conditions:default": [
            "-Wno-sign-compare",
            "-Wno-unused-but-set-variable",
            "-Wno-unused-variable",
        ],
    }),
    defines = [
        "BT_USE_DOUBLE_PRECISION",
    ],
    includes = ["src"],
    visibility = ["//visibility:public"],
    deps = [":LinearMathDoublePrecision"],
)

cc_library(
    name = "BulletDynamics",
    srcs = glob([
        "src/BulletDynamics/**/*.cpp",
    ]),
    hdrs = glob([
        "src/BulletDynamics/**/*.h",
    ]) + [
        "src/btBulletDynamicsCommon.h",
    ],
    copts = select({
        "@platforms//os:windows": [],
        "//conditions:default": [
            "-Wno-class-memaccess",
            "-Wno-reorder",
            "-Wno-unknown-warning-option",
            "-Wno-unused-but-set-variable",
            "-Wno-unused-function",
            "-Wno-unused-variable",
        ],
    }),
    includes = ["src"],
    visibility = ["//visibility:public"],
    deps = [
        ":BulletCollision",
        ":LinearMath",
    ],
)

cc_library(
    name = "BulletDynamicsDoublePrecision",
    srcs = glob([
        "src/BulletDynamics/**/*.cpp",
    ]),
    hdrs = glob([
        "src/BulletDynamics/**/*.h",
    ]) + [
        "src/btBulletDynamicsCommon.h",
    ],
    copts = select({
        "@platforms//os:windows": [],
        "//conditions:default": [
            "-Wno-class-memaccess",
            "-Wno-reorder",
            "-Wno-unknown-warning-option",
            "-Wno-unused-but-set-variable",
            "-Wno-unused-function",
            "-Wno-unused-variable",
        ],
    }),
    defines = [
        "BT_USE_DOUBLE_PRECISION",
    ],
    includes = ["src"],
    visibility = ["//visibility:public"],
    deps = [
        ":BulletCollisionDoublePrecision",
        ":LinearMathDoublePrecision",
    ],
)

cc_library(
    name = "BulletSoftBody",
    srcs = glob([
        "src/BulletSoftBody/**/*.cpp",
        "src/BulletSoftBody/*.cpp",
    ]),
    hdrs = glob([
        "src/BulletSoftBody/**/*.h",
        "src/BulletSoftBody/*.h",
    ]),
    copts = select({
        "@platforms//os:windows": [],
        "//conditions:default": [
            "-Wno-class-memaccess",
            "-Wno-implicit-const-int-float-conversion",
            "-Wno-overloaded-virtual",
            "-Wno-reorder",
            "-Wno-sign-compare",
            "-Wno-single-bit-bitfield-constant-conversion",
            "-Wno-unknown-warning-option",
            "-Wno-unused-but-set-variable",
            "-Wno-unused-variable",
        ],
    }),
    includes = ["src"],
    visibility = ["//visibility:public"],
    deps = [
        ":BulletCollision",
        ":BulletDynamics",
        ":LinearMath",
    ],
)

cc_library(
    name = "BulletSoftBodyDoublePrecision",
    srcs = glob([
        "src/BulletSoftBody/**/*.cpp",
        "src/BulletSoftBody/*.cpp",
    ]),
    hdrs = glob([
        "src/BulletSoftBody/**/*.h",
        "src/BulletSoftBody/*.h",
    ]),
    copts = select({
        "@platforms//os:windows": [],
        "//conditions:default": [
            "-Wno-class-memaccess",
            "-Wno-implicit-const-int-float-conversion",
            "-Wno-overloaded-virtual",
            "-Wno-reorder",
            "-Wno-sign-compare",
            "-Wno-single-bit-bitfield-constant-conversion",
            "-Wno-unknown-warning-option",
            "-Wno-unused-but-set-variable",
            "-Wno-unused-variable",
        ],
    }),
    defines = [
        "BT_USE_DOUBLE_PRECISION",
    ],
    includes = ["src"],
    visibility = ["//visibility:public"],
    deps = [
        ":BulletCollisionDoublePrecision",
        ":BulletDynamicsDoublePrecision",
        ":LinearMathDoublePrecision",
    ],
)

cc_library(
    name = "Bullet3Common",
    srcs = glob(["src/Bullet3Common/*.cpp"]),
    hdrs = glob([
        "src/Bullet3Common/**/*.h",
        "src/Bullet3Common/*.h",
    ]),
    includes = ["src"],
)

cc_library(
    name = "BulletInverseDynamics",
    srcs = glob([
        "src/BulletInverseDynamics/**/*.cpp",
        "src/BulletInverseDynamics/*.cpp",
    ]),
    hdrs = glob([
        "src/BulletInverseDynamics/**/*.hpp",
        "src/BulletInverseDynamics/*.hpp",
    ]),
    copts = select({
        "@platforms//os:windows": [],
        "//conditions:default": [
            "-Wno-unused-but-set-variable",
        ],
    }),
    includes = ["src"],
    visibility = ["//visibility:public"],
    deps = [
        ":Bullet3Common",
        ":BulletDynamics",
        ":LinearMath",
    ],
)

cc_library(
    name = "BulletInverseDynamicsDoublePrecision",
    srcs = glob([
        "src/BulletInverseDynamics/**/*.cpp",
        "src/BulletInverseDynamics/*.cpp",
    ]),
    hdrs = glob([
        "src/BulletInverseDynamics/**/*.hpp",
        "src/BulletInverseDynamics/*.hpp",
    ]),
    copts = select({
        "@platforms//os:windows": [],
        "//conditions:default": [
            "-Wno-unused-but-set-variable",
        ],
    }),
    defines = [
        "BT_USE_DOUBLE_PRECISION",
    ],
    includes = ["src"],
    visibility = ["//visibility:public"],
    deps = [
        ":Bullet3Common",
        ":BulletDynamicsDoublePrecision",
        ":LinearMathDoublePrecision",
    ],
)

cc_library(
    name = "Bullet3Geometry",
    srcs = glob(["src/Bullet3Geometry/*.cpp"]),
    hdrs = glob(["src/Bullet3Geometry/*.h"]),
    includes = ["src"],
    visibility = ["//visibility:public"],
    deps = [
        ":Bullet3Common",
    ],
)

cc_library(
    name = "Bullet3Collision",
    srcs = glob(["src/Bullet3Collision/**/*.cpp"]),
    hdrs = glob(["src/Bullet3Collision/**/*.h"]),
    includes = ["src"],
    visibility = ["//visibility:public"],
    deps = [
        ":Bullet3Common",
        ":Bullet3Geometry",
    ],
)

cc_library(
    name = "Bullet3Dynamics",
    srcs = glob([
        "src/Bullet3Dynamics/**/*.cpp",
        "src/Bullet3Dynamics/*.cpp",
    ]),
    hdrs = glob([
        "src/Bullet3Dynamics/**/*.h",
        "src/Bullet3Dynamics/*.h",
    ]),
    includes = ["src"],
    visibility = ["//visibility:public"],
    deps = [
        ":Bullet3Collision",
        ":Bullet3Common",
    ],
)

cc_library(
    name = "Bullet3Serialize",
    srcs = glob(["src/Bullet3Serialize/**/*.cpp"]),
    hdrs = glob(["src/Bullet3Serialize/**/*.h"]),
    copts = select({
        "@platforms//os:windows": [],
        "//conditions:default": [
            "-Wno-class-memaccess",
            "-Wno-unknown-warning-option",
            "-Wno-unused-but-set-variable",
            "-Wno-unused-variable",
        ],
    }),
    includes = ["src"],
    visibility = ["//visibility:public"],
    deps = [
        ":Bullet3Common",
    ],
)
